package com.example.demo;

import com.example.demo.model.ReadList;
import com.example.demo.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张杰
 * Date: 2022-07-28
 * Time: 16:08
 */
@Controller
public class UserController {

    @Value("${server.port}")
    private String port;

    @Value("${mystring}") // 读取配置项
    private String mystring;

    @Value("${mystring2}") // 读取配置项
    private String mystring2;

    @Value("${mystring3}") // 读取配置项
    private String mystring3;

    @Autowired
    private Student student;

    @Resource
    private ReadList readList;

    @ResponseBody // 返回一个非静态页面的数据
    @RequestMapping("/sayhi")//配置路由,使用一级目录就可以访问到该方法,
    // sayhi需要都设置成小写,否则可能会导致不同的服务器上不兼容问题
    public String sayHi() {
        /*System.out.println("mystring"+mystring);
        System.out.println("mystring2"+mystring2);
        System.out.println("mystring3"+mystring3);
        return "Hello,World!"+port;*/

//        return "student:"+student;

        return "readList:" + readList.getName();
    }
}
